#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;

using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;

  vector<pair<ll, ll>> bottle;

  for (int i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    bottle.push_back({a - b, a});
  }
  sort(bottle.begin(),    bottle.end()); 
  // 按照 a-b 排序 ，如果a-b 一样，则按照a排序

  ll ans = 0;
  for (auto v : bottle) {

    ll res = v.first;
    ll lim = v.second;

    if (n < lim)
      continue;
    ll dis = n - lim;
    ll cnt = (dis / res) + 1LL;
    ans += cnt;
    n -= cnt * res;
  }

  cout << ans << endl;
  return 0;
}
